package cn.wokoba.service.activity.service.state.handler;

import cn.wokoba.service.activity.model.ActivityStateVO;
import cn.wokoba.service.activity.service.state.IActivityState;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Service
@Slf4j
public class ActivityStateHandler {

    private static final Map<Enum<ActivityStateVO>, IActivityState> stateMap = new ConcurrentHashMap<>();

    protected static void register(Enum<ActivityStateVO> status, IActivityState state) {
        stateMap.put(status, state);
    }

    public boolean check(Long activityId,ActivityStateVO currentStatus) {
        return stateMap.get(currentStatus).check(activityId,currentStatus);
    }

    public boolean pass(Long activityId, ActivityStateVO currentStatus) {
        return stateMap.get(currentStatus).pass(activityId, currentStatus);
    }

    public boolean open(Long activityId, ActivityStateVO currentStatus) {
        return stateMap.get(currentStatus).open(activityId, currentStatus);

    }

    public boolean create(Long activityId, ActivityStateVO currentStatus) {
        return stateMap.get(currentStatus).create(activityId, currentStatus);

    }

    public boolean closed(Long activityId, ActivityStateVO currentStatus) {
        return stateMap.get(currentStatus).closed(activityId, currentStatus);
    }


}
